home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: dos.h equivalent in gcc or cc ?
- Date: 16 Apr 1996 15:42:40 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Distribution: inet
- Message-ID: <4l17p0INNf6v@keats.ugrad.cs.ubc.ca>
- References: <3173B701.41C6@ieec.fcr.es>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <3173B701.41C6@ieec.fcr.es>, Oscar Chic <chic@ieec.fcr.es> wrote:
- >I'm trying to pass arguments to a function with _argv and _argc
- >global variables that Borland 4.5 permits.
-
- ...and which are not portable anywhere, really.
-
- >In Borland you must do an include of dos.h
- >Which is the equivalent in gcc or cc in a UNIX WS ?
-
- It's called...
-
- int main(int argc, char **argv)
-
- >Which file must I include to do the same ?
-
- None. Just declare a pair of external variables (outside of any function, of
- course)
-
- int global_argc;
- char **global_argv;
-
-
- Make these known to other programs with appropriate ``extern'' declarations in
- your own private header.
-
- Then, inside the main() function, simply assign the arguments to these:
-
- int main(int argc, char **argv)
-
- {
- global_argc = argc;
- global_argv = argv;
-
- .
- .
- .
-
- }
-
- This is portable, so you don't have to worry when you port away from the
- Borland environment.
-
- Declaring your own identifiers that begin with _ is illegal according to the C
- language standard, so in order to make Borland's mechanism work elsewhere you
- would have to violate the standard.
- --
- I'm not really a jerk, but I play one on Usenet.
-